package hikari.instruments;

import hikari.objects3d.Basic3dObject;
import java.awt.Canvas;
import java.awt.Cursor;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;

/**
 * @author sad
 */
public abstract class HikariInstrument {

    private Canvas mainScreen;
    private Cursor cursor;

    public Cursor getCursor() {
        return cursor;
    }

    public void setCursor(Cursor cursor) {
        this.cursor = cursor;
    }
    
    public Canvas getMainScreen() {
        return mainScreen;
    }

    public void setMainScreen(Canvas mainScreen) {
        this.mainScreen = mainScreen;
    }
    
    /**
     * @param x
     * @param y
     * @param button 1-left,2-wheel, 3-right
     * @param modifier
     */
    public void mouseDown(int x, int y, int button, int modifier) {
    }

    /**
     * @param x
     * @param y
     * @param button 1-left,2-wheel, 3-right
     * @param modifier
     */
    public void mouseUp(int x, int y, int button, int modifier) {
    }

    /**
     * @param x
     * @param y
     * @param button 1-left,2-wheel, 3-right
     * @param modifier
     */
    public void mouseDblClick(int x, int y, int button, int modifier) {
    }

    /**
     * @param x
     * @param y
     * @param button 1-left,2-wheel, 3-right
     * @param modifier
     */
    public void mouseClick(int x, int y, int button, int modifier) {
    }
    
    public void instrumentActivate(){
        
    }
    
    public void instrumentDeactivate(){
    
    }

    public void mouseMove(int x, int y, int dx, int dy, int modifier) {
    }

    public void mouseWheel(int x, int y, int wheel, int modifier) {
    }

    public void keyDown(KeyEvent key) {
    }

    public void keyUp(KeyEvent key) {
    }

    public void keyType(KeyEvent key) {
    }

    /**
     * Check if the alt pressed.<br/> Works only with mouse events
     *
     * @return
     */
    public boolean isShiftPressed(int modifier) {
        return (modifier & MouseEvent.SHIFT_DOWN_MASK) != 0;
    }

    /**
     * Check if the alt pressed.<br/> Works only with mouse events
     *
     * @return
     */
    public boolean isCtrlPressed(int modifier) {
        return (modifier & MouseEvent.CTRL_DOWN_MASK) != 0;
    }

    /**
     * Check if the alt pressed.<br/> Works only with mouse events
     *
     * @return
     */
    public boolean isAltPressed(int modifier) {
        return (modifier & MouseEvent.ALT_DOWN_MASK) != 0 || (modifier & MouseEvent.ALT_GRAPH_DOWN_MASK) != 0;
    }

    public boolean isLeftMouseDown(int modifier) {
        return (modifier & MouseEvent.BUTTON1_DOWN_MASK) != 0;
    }
    
    public boolean isOnlyLeftMouseDown(int modifier){
        return isLeftMouseDown(modifier)&& !isRightMouseDown(modifier) && !isWheelDown(modifier);
    }
    
    public boolean isOnlyRightMouseDown(int modifier){
        return !isLeftMouseDown(modifier)&& isRightMouseDown(modifier) && !isWheelDown(modifier);
    }
    
    public boolean isOnlyWheelMouseDown(int modifier){
        return !isLeftMouseDown(modifier)&& !isRightMouseDown(modifier) && isWheelDown(modifier);
    }

    public boolean isRightMouseDown(int modifier) {
        return (modifier & MouseEvent.BUTTON3_DOWN_MASK) != 0;
    }

    public boolean isWheelDown(int modifier) {
        return (modifier & MouseEvent.BUTTON2_DOWN_MASK) != 0;
    }

    public void selectObject(Basic3dObject currentSelection, Basic3dObject newSelection) {
    }
    
    public void onBeforeRender(){}
    public void onAfterRenderBeforeGui(){}
    public void onAfterRender(){}
    
    
    
}
